From d83b11f1bbfd1b51c0a4dfb561850802cce3c545 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Mon, 24 Aug 2020 01:30:48 -0500 Subject: [PATCH] Allow client retry on a redirect of an upgrade check. Not in this CL, server side change to NOT force an http->https upgrade on this one URL. --- gui/upgrade.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gui/upgrade.cc b/gui/upgrade.cc index 2c0eed1e1..4f6c2c1c8 100644 --- a/gui/upgrade.cc +++ b/gui/upgrade.cc @@ -113,6 +113,11 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade( this, SLOT(httpRequestFinished(QNetworkReply*))); QNetworkRequest request = QNetworkRequest(upgradeUrl_); + + // In Qt 5.6 and later, it can reissue with a redirect. With this in + // place, we don't see the 301 redirect, but the server has to issue + // one for the thousands of older clients out there. + request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("Accept-Encoding","identity"); @@ -171,10 +176,10 @@ UpgradeCheck::updateStatus UpgradeCheck::getStatus() } // GPSBabel version numbers throughout the code mostly predate QVersionNumber -// and are stored as strings. They may be of the form "1.6.0-beta20200413" +// and are stored as strings. They may be of the form "1.6.0-beta20200413" // which, if sorted as a string, will be after "1.6.0" which is bad. Use -// this function to sort that out. (See what I did there? Bwaaaahah!) -bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to) +// this function to sort that out. (See what I did there? Bwaaaahah!) +bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to) { int fromIndex = 0; int toIndex = 0; @@ -186,7 +191,7 @@ bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to) if (fromVersion < toVersion) { return true; } - // Just look for the presence of stuff (not even the contents) of the + // Just look for the presence of stuff (not even the contents) of the // string. Shorter string (no "-betaXXX" wins) if (fromVersion == toVersion) { if (from.length() - fromIndex > to.length() - toIndex) { @@ -195,7 +200,7 @@ bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to) } return false; } -// Some day when we have Gunit or equiv, add unit tests for: +// Some day when we have Gunit or equiv, add unit tests for: //suggestUpgrade(updateVersion, currentVersion_); //suggestUpgrade("1.6.0-beta20190413", "1.6.0"); //suggestUpgrade("1.6.0", "1.6.0-beta20190413"); -- 2.30.2